home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / idn / idn.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  2.6 KB  |  70 lines

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // The following simple demonstration program uses the Standard 
  4. // Instrument Control Library to query an GPIB instrument for
  5. // an identification string and then prints the result.
  6. //
  7. // Edit the DEVICE_ADDRESS line below to specify the address of the 
  8. // device you want to talk to.  For example:
  9. //
  10. //     hpib7,0    - refers to an GPIB device at bus address 0 
  11. //                  connected to an interface named "hpib7" by the 
  12. //                  I/O Config utility.
  13. //
  14. //     hpib7,9,0  - refers to an GPIB device at bus address 9, 
  15. //                  secondary address 0, connected to an interface 
  16. //                  named "hpib7" by the I/O Config utility.
  17. //
  18. // Note that this program is meant to be built either as a WIN16 
  19. // QuickWin or EasyWin program on 16 bit Windows 95, or as a WIN32
  20. // console application on 32 bit Windows 95 or Windows NT.  Also 
  21. // note that WIN16 programs must be compiled with the Large memory 
  22. // model.
  23. //
  24. /////////////////////////////////////////////////////////////////////
  25.  
  26. #include <stdio.h>              // for printf()
  27. #include "sicl.h"        // Standard Instrument Control Library routines
  28.  
  29. #define DEVICE_ADDRESS "hpib7,0"   // Modify this line to match your setup
  30.  
  31. void main(void)
  32. {
  33.    INST id;                     // device session id
  34.    char buf[256] = { 0 };       // read buffer for idn string
  35.  
  36.    #if defined(__BORLANDC__) && !defined(__WIN32__)
  37.      _InitEasyWin();        // required for Borland EasyWin programs.
  38.    #endif
  39.  
  40.    // Install a default SICL error handler that logs an error message and
  41.    // exits.  On Windows 95 view messages with the SICL Message Viewer,
  42.    // and on Windows NT use the Windows NT Event Viewer.
  43.    ionerror(I_ERROR_EXIT);    
  44.  
  45.    // Open a device session using the DEVICE_ADDRESS
  46.    id = iopen(DEVICE_ADDRESS);
  47.  
  48.    // Set the I/O timeout value for this session to 1 second
  49.    itimeout(id, 1000);
  50.   
  51.    // Write the *RST string (and send an EOI indicator) to put the instrument
  52.    // in a known state.
  53.    iprintf(id, "*RST\n");
  54.  
  55.    // Write the *IDN? string and send an EOI indicator, then read
  56.    // the response into buf.  
  57.    // For WIN16 programs, this will only work with the Large memory model 
  58.    // since ipromptf expects to receive far pointers to the format strings.
  59.  
  60.    ipromptf(id, "*IDN?\n", "%t", buf);
  61.    printf("%s\n", buf);
  62.  
  63.    iclose(id);
  64.  
  65.    // For WIN16 programs, call _siclcleanup before exiting to release 
  66.    // resources allocated by SICL for this application.  This call is a
  67.    // no-op for WIN32 programs.
  68.    _siclcleanup();
  69. }
  70.